package com.ruoyi.business.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.business.domain.CzEquipmentType;
import com.ruoyi.business.service.ICzEquipmentTypeService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 设备类型Controller
 * 
 * @author ruoyi
 * @date 2022-01-09
 */
@Api(tags = "设备类型")
@RestController
@RequestMapping("/business/equipment_type")
public class CzEquipmentTypeController extends BaseController
{
    @Autowired
    private ICzEquipmentTypeService czEquipmentTypeService;

    /**
     * 查询设备类型列表
     */
    @ApiOperation(value = "查询设备类型列表")
    @PreAuthorize("@ss.hasPermi('business:equipment_type:list')")
    @GetMapping("/list")
    public TableDataInfo list(CzEquipmentType czEquipmentType)
    {
        startPage();
        List<CzEquipmentType> list = czEquipmentTypeService.selectCzEquipmentTypeList(czEquipmentType);
        return getDataTable(list);
    }

    /**
     * 导出设备类型列表
     */
    @ApiOperation(value = "导出设备类型列表")
    @PreAuthorize("@ss.hasPermi('business:equipment_type:export')")
    @Log(title = "设备类型", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, CzEquipmentType czEquipmentType)
    {
        List<CzEquipmentType> list = czEquipmentTypeService.selectCzEquipmentTypeList(czEquipmentType);
        ExcelUtil<CzEquipmentType> util = new ExcelUtil<CzEquipmentType>(CzEquipmentType.class);
        util.exportExcel(response, list, "设备类型数据");
    }

    /**
     * 获取设备类型详细信息
     */
    @ApiOperation(value = "获取设备类型详细信息")
    @PreAuthorize("@ss.hasPermi('business:equipment_type:query')")
    @GetMapping(value = "/{equipmentTypeId}")
    public AjaxResult getInfo(@PathVariable("equipmentTypeId") String equipmentTypeId)
    {
        return AjaxResult.success(czEquipmentTypeService.selectCzEquipmentTypeByEquipmentTypeId(equipmentTypeId));
    }

    /**
     * 新增设备类型
     */
    @ApiOperation(value = "新增设备类型")
    @PreAuthorize("@ss.hasPermi('business:equipment_type:add')")
    @Log(title = "设备类型", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody CzEquipmentType czEquipmentType)
    {
        return toAjax(czEquipmentTypeService.insertCzEquipmentType(czEquipmentType));
    }

    /**
     * 修改设备类型
     */
    @ApiOperation(value = "修改设备类型")
    @PreAuthorize("@ss.hasPermi('business:equipment_type:edit')")
    @Log(title = "设备类型", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody CzEquipmentType czEquipmentType)
    {
        return toAjax(czEquipmentTypeService.updateCzEquipmentType(czEquipmentType));
    }

    /**
     * 删除设备类型
     */
    @ApiOperation(value = "删除设备类型")
    @PreAuthorize("@ss.hasPermi('business:equipment_type:remove')")
    @Log(title = "设备类型", businessType = BusinessType.DELETE)
	@DeleteMapping("/{equipmentTypeIds}")
    public AjaxResult remove(@PathVariable String[] equipmentTypeIds)
    {
        return toAjax(czEquipmentTypeService.deleteCzEquipmentTypeByEquipmentTypeIds(equipmentTypeIds));
    }
}
